﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Runtime.Serialization;

namespace Common.Model
{
    [DataContract]
    public class CBase
    {
        /// <summary>
        /// vergleicht alle public eigenschaften zweier objekte
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            try
            {
                if (obj == null) return false;
                if (obj.GetType() != this.GetType()) return false;

                foreach (var item in obj.GetType().GetProperties())
                {
                    if (!item.GetValue(obj, null).Equals(item.GetValue(this, null)))
                        return false;
                }
                return true;
            }
            catch (Exception)
            {
                return base.Equals(obj);
            }
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
    }
}
